package aryn.blog.dialog;

import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;

import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JOptionPane;

public class ImageDialog {
	private JFrame frame;

	public ImageDialog(JFrame frame) {
		this.frame = frame;
	}
	
	public JButton generateButton(String filename, int x, int y, String message) {
		ImageIcon img = new ImageIcon(filename);
		JButton button = new JButton(img);
		button.setBorder(null);
		button.setBounds(x, y, img.getIconWidth(), img.getIconHeight());
		button.addActionListener(new MyActionListener(message));
		return button;
	}

	public class MyActionListener implements ActionListener {
		private String message;
		
		public MyActionListener(String message) {
			this.message = message;
		}

		public void actionPerformed(ActionEvent e) {
			JOptionPane.showMessageDialog(frame, message);
		}
	}
}